import 'dart:ui';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutterwebsite/model/product.dart';
import 'package:flutterwebsite/pages/product_list_page.dart';
import 'package:flutterwebsite/services/product_service.dart';
class ProductPage extends StatefulWidget{

  @override
  ProductState createState() =>ProductState();



}
class ProductState extends State<ProductPage>{
  @override
  void initState() {
    getProductList();
    super.initState();
  }

  //listview数据源
  ProductListModel listData=ProductListModel([]);

  int page=0;
  //从服务器获取数据
  void getProductList() async{
    var data= await getProductsResult(page++);
    ProductListModel list=ProductListModel.fromJson(data);
    setState(() {
      listData.data.addAll(list.data);
    });
  }

  @override
  Widget build(BuildContext context) {
    return ProductResultListPage(listData,getNextPage:()=>getProductsResult() );
  }
}